package com.dz.fz.modal;

import com.dz.fz.bean.userBean;
import com.dz.fz.dao.DBProvider;
import com.dz.fz.utils.myUtils;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.ArrayList;
import java.util.List;

public class userFileAddModal {
    public int doInsert(userBean userB){
        int i = 0;
        String strSql = "INSERT INTO usernew (userName,userPsw,userAddress,userTel,RegDate,userImg) VALUES(?,?,?,?,?,?)";
        i = DBProvider.update(strSql,userB.getUserName(),userB.getUserPsw(),userB.getUserAddress(),userB.getUserTel(), myUtils.Date2String(userB.getRegDate(),"yyyy-MM-dd HH:mm:ss"),userB.getUserImg());
        return i;
    }
    public List<userBean> doSelect(boolean desc){
       String strSql = "SELECT * FROM usernew";
        strSql = desc ==true?strSql+" ORDER BY userId DESC":strSql;
        List<userBean> list = DBProvider.query(strSql,new BeanListHandler<>(userBean.class));
        return list;
    }
}
